import time


def gen_timestamp_str():
    """
    生成 时间戳 %Y-%m-%d %H:%M:%S
    """
    return time.strftime(r"%Y-%m-%d %H:%M:%S")

def gen_current():
    """
    获取当天的日期字符串和时间戳
    """
    current_date = str(time.strftime(r"%Y-%m-%d 00:00:00"))
    
    current_date_timestamp = int(time.mktime(time.strptime(current_date,r"%Y-%m-%d %H:%M:%S")))

    return current_date,current_date_timestamp

def gen_start_end_date(timestamp):
    """
    timestamp : 日期时间戳
    return : 该日期对应的起始时间戳  
    2023-08-22 00:00:00 2023-08-23 00:00:00
    """
    start_date = str(time.strftime(r"%Y-%m-%d %H:%M:%S",time.localtime(timestamp)))

    next_date = str(time.strftime(r"%Y-%m-%d %H:%M:%S",time.localtime(timestamp + 86400)))

    return start_date,next_date

def gen_time_diff(_date,diff_day = 0,diff_hour=0,diff_min = 0 ,diff_s = 0):
    """
    _date : 具体的时间，可以是时间戳 ，也可以是标准时间格式 
    ```
    时间: 2021-08-08 00:00:00
    时间戳: 1628352000
    ```
    diff_day : 天数差
    diff_hour: 小时差
    diff_min: 分钟差
    diff_s: 秒数差
    

    得到该日期之前或者之后一段时间的日期
    _date 2023-09-06 00:00:00   
    return 2023-09-07 00:00:00   
    """

    time_diff = diff_day*86400 + diff_hour*3600 + diff_min* 60 + diff_s
    
    if isinstance(_date,str):
        date_start_timestamp = time.mktime(time.strptime(_date,r"%Y-%m-%d %H:%M:%S"))
    else:
        date_start_timestamp = _date

    next_date = str(time.strftime(r"%Y-%m-%d %H:%M:%S",time.localtime(date_start_timestamp + time_diff)))

    return next_date


if __name__ =="__main__":
    res = gen_current()
    print(res)

    res = gen_next_date("2023-09-06 00:00:00")
    _date = "2023-09-06 00:00:00"
    res = _date.replace("-","_")[:9]
    print(res)